﻿using System.Windows.Input;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UITesting.WpfControls;

namespace CodedUITestExtensions
{
    /// <summary>
    /// Extensions for keyboard.
    /// </summary>
    public static class KeyboardExtension
    {
        /// <summary>
        /// Enters text in WpfEdit (used for the blocked controls).
        /// </summary>
        /// <param name="keyboard">Keyboard.</param>
        /// <param name="textBox">WpfEdit.</param>
        /// <param name="text">Input text.</param>
        public static void SendKeysToWpfEdit(this Keyboard keyboard, WpfEdit textBox, string text)
        {
            if (text.Length == 0)
            {
                text = "{DELETE}";
                Keyboard.SendKeys(textBox, "A", ModifierKeys.Control);    
            }
            Keyboard.SendKeys(textBox, text, ModifierKeys.None);    
        }
    }
}
